﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using senac.ws.interfaces;
using senac.ws.negocio;
using System.Threading;
using senac.util;

namespace senac.ws.Teste
{
    class Program
    {
        static void Main(string[] args)
        {
            Util.Instance.EscreverLog(Util.opcoesEscrita.EscreverInicio, string.Empty);
            Console.WriteLine("Início --> " + DateTime.Now.ToString("HH:mm:ss"));

            while (true)
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();

                Negocio.Instance.AnalisarTabelas();

                Console.WriteLine("Mensagem --> " + DateTime.Now.ToString("HH:mm:ss"));

                int tempoPassado = 0;
                if (Int32.TryParse(stopwatch.ElapsedMilliseconds.ToString(), out tempoPassado))
                {
                    //if (tempoPassado < 300000)
                    //    Thread.Sleep(300000 - tempoPassado);
                    if (tempoPassado < 180000)
                        Thread.Sleep(180000 - tempoPassado);
                }
            }
        }
    }
}
